package com.cbtx.module_sp.ui.activity

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import com.cbtx.module.common.ui.TouFangLocationAdapter
import com.cbtx.module.common.vm.LoginVM
import com.cbtx.module.common.vm.TouFangLocationVM
import com.cbtx.module_sp.MyApplication
import com.cbtx.module_sp.R
import com.cbtx.module_sp.TaskService
import com.cbtx.module_sp.ui.activity.base.MyBaseVMActivity
import com.txcb.lib.base.utils.LoadingDialogUtil
import com.txcb.lib.base.utils.LogUtil
import kotlinx.android.synthetic.main.sp_activity_login_select_position.*

/**
 * 公司投放
 */
class TouFangLocationActivity : MyBaseVMActivity<TouFangLocationVM>() {

    companion object {
        fun start(activity: Activity) {
            val intent = Intent(activity, TouFangLocationActivity::class.java)
            activity.startActivity(intent)
        }
    }

    var mAdapter: TouFangLocationAdapter? = null

    override fun getPresenterClazz(): Class<TouFangLocationVM> {
        return TouFangLocationVM::class.java
    }

    override fun getLayoutId(): Int {
        return R.layout.sp_activity_login_select_position
    }

    override fun initView(savedInstanceState: Bundle?) {

//        LoadingDialogUtil.showDialog(mActivity, "加载中")

//        mTvCode.text = "云屏编码:${MyApplication.mAndroidId}"
//
//        addClickListener(mTvBack)
//        mAdapter = TouFangLocationAdapter(R.layout.sp_item_toufang_location, mVM.mDatas.value)
//        mRvLocation.layoutManager = LinearLayoutManager(mContext)
//        mRvLocation.adapter = mAdapter
//
//        mAdapter?.setOnItemClickListener { adapter, view, position ->
//            val areaItem = mVM.mDatas.value?.get(position)
//            LoginActivity.start(mActivity, LoginVM.LOGIN_COMPANY, areaItem?.id!!)
//        }
//
//        mTouchView.setOnTouchListener { view, motionEvent ->
//            LogUtil.d("mTouchView")
//            TaskService.activityTouchTime = System.currentTimeMillis()
//            checkTouch(motionEvent)
//            return@setOnTouchListener false
//        }
//
//        mTouchLongView.setOnLongClickListener {
//            toNetSet()
//            return@setOnLongClickListener false
//        }

//        mVM.mDatas.observe(this, Observer {
//            mAdapter?.setNewData(it)
//            LoadingDialogUtil.closeDialog()
//        })
    }

    override fun onMyViewClick(view: View) {
//        if (view.id == R.id.mTvBack) {
//            finish()
//        }
    }

    override fun getData() {
//        mVM.getLocationList()
    }
}